package cxt

import (
	"github.com/name5566/leaf/gate"
	"talent.com/cube/conf/g"
)

func GetUserAgent(userID uint64) gate.Agent {
	if tmp, ok := g.AllAgents.Load(userID); ok {
		ag := tmp.(gate.Agent)
		return ag
	}
	return nil
}

func GetTableContext(tableId int64) *TableContext {
	if tc, ok := g.AllTables.Load(tableId); ok {
		return tc.(*TableContext)
	}
	return nil
}

func GetUserContext(userID uint64) *UserContext {
	if tmp, ok := g.AllAgents.Load(userID); ok {
		ag := tmp.(gate.Agent)
		return ag.UserData().(*UserContext)
	}
	return nil
}
